/*****************************************************
Copyright (C) 2020. All rights reserved.
File name     ：LeftistHeap.h
Version       ：v1.0
Author        ：zhengqijun
Date          ：2020-04-07
Function List ：
Description   ：Leftist Heap
******************************************************/

#ifndef LEFTISTHEAP_H_
#define LEFTISTHEAP_H_

// Type Definition
struct TreeNode;
typedef int ElementType;
typedef struct TreeNode *Position;
typedef struct TreeNode *PriorityQueue;

/* Minimal set of priority queue operations */
/* Note that nodes will be shared among several */
/* leftist heaps after a merge; the user must */
/* make sure to not use the old leftist heaps */

// Function Lists
PriorityQueue Initialize(void);
PriorityQueue Destroy(PriorityQueue H);
ElementType FindMin(PriorityQueue H);
int IsEmpty(PriorityQueue H);
PriorityQueue Merge(PriorityQueue H1, PriorityQueue H2);

#define Insert(X, H) (H = Insert1((X), H))
#define DeleteMin(H) (H = DeleteMin1(H))

PriorityQueue Insert1(ElementType X, PriorityQueue H);
PriorityQueue DeleteMin1(PriorityQueue H);

Position Left(Position P);
Position Right(Position P);
ElementType Retrieve(Position P);

#endif  /* LEFTISTHEAP_H_ */

// EOF

